const express = require('express');
const router = express.Router()

const { getPostCount, getPostList, searchPost, toggleHotPost, deletePost } = require('../../controller/apis/PostController');
// 导入JWT拦截中间件
const checkTokenMiddleware = require('../../middleware/checkTokenMiddleware')
// 导入分页中间件
const paginationMiddleware = require('../../middleware/paginationMiddleware');

// 获取攻略总数
router.get('/post/count', checkTokenMiddleware, getPostCount)

// 获取攻略列表数据
router.get('/post/list', paginationMiddleware, checkTokenMiddleware, getPostList)

// 攻略列表搜索功能
router.get('/post/search', checkTokenMiddleware, searchPost)

// 攻略热门状态切换
router.patch('/post/hot/toggle/:id', checkTokenMiddleware, toggleHotPost)

// 删除攻略
router.delete('/post/del/:id', checkTokenMiddleware, deletePost)

module.exports = router